import { reqAcademyPoint } from '@/api';
import { reqAcademyLink } from '@/api';
import { reqOfficePoint } from '@/api';
import { reqOfficeLink } from '@/api';

const state = {
  data: [],
  links: [],
};
const mutations = {
  GETACADEMYPOINT(state, data) {
    state.data = data;
  },
  GETACADEMYLINK(state, links) {
    state.links = links;
  },
  GETOFFICEPOINT(state, data) {
    state.data = data;
  },
  GETOFFICELINK(state, links) {
    state.links = links;
  },
};
const actions = {
  async getAcademyPoint({ commit }, id) {
    let result = await reqAcademyPoint(id);
    if (result.code == 1) {
      commit('GETACADEMYPOINT', result.data);
    }
  },
  async getOfficePoint({ commit }, id) {
    let result = await reqOfficePoint(id);
    if (result.code == 1) {
      commit('GETOFFICEPOINT', result.data);
    }
  },
  // 根据书院id获取
  async getAcademyLink({ commit }, id) {
    let result = await reqAcademyLink(id);
    if (result.code == 1) {
      commit('GETACADEMYLINK', result.data);
    }
  },
  async getOfficeLink({ commit }, id) {
    let result = await reqOfficeLink(id);
    if (result.code == 1) {
      commit('GETOFFICELINK', result.data);
    }
  },
};
const getters = {};

export default {
  state,
  mutations,
  actions,
  getters,
};
